package com.kingsoft.miot.bridge.service.impl.manager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kingsoft.miot.bridge.dao.manager.ManagerGroupRecordDao;
import com.kingsoft.miot.bridge.exception.CommonException;
import com.kingsoft.miot.bridge.pojo.manager.ManagerGroupRecord;
import com.kingsoft.miot.bridge.service.manager.ManagerGroupRecordService;

/**
 * 管理者记录 服务
 * 
 * @author HUJIANQING
 *
 */
@Service
public class ManagerGroupRecordServiceImpl implements ManagerGroupRecordService {

	private static final Logger LOGGER = LoggerFactory.getLogger(ManagerGroupRecordServiceImpl.class);

	@Autowired
	private ManagerGroupRecordDao managerGroupRecordDao;

	/**
	 * 通过manager id 获得管理者权限记录
	 */
	@Override
	public ManagerGroupRecord getByManagerId(int manager_info_id) {
		try {
			return managerGroupRecordDao.getByManagerId(manager_info_id);
		} catch (Exception e) {

			LOGGER.error("查询管理者权限组失败。");
			throw new CommonException(e);
		}
	}

	/**
	 * 新增数据
	 */
	@Override
	public void insertOne(ManagerGroupRecord managerGroupRecord) {
		try {
			managerGroupRecordDao.insertOne(managerGroupRecord);
			LOGGER.info("新增管理员权限记录成功.");
		} catch (Exception e) {
			throw new CommonException(e);
		}
	}

}
